package com.kikoulol.jarmoryextactor;

import org.apache.xmlbeans.XmlException;

import com.kikoulol.jarmoryextactor.utils.Utils;

import noNamespace.CharacterTab;
import noNamespace.PageDocument;
import noNamespace.ItemTooltipDocument.ItemTooltip;


public class Item {

	// XML FILE
	noNamespace.Item itemXml;

	private String id;
	private String name;
	private String icon;
	private String heroic;
	private String overallQualityId;
	private String bonding;
	private String classId;
	private String equipData;
	private String damageData;
	private String bonusStrength;
	private String bonusStamina;
	private String armor;
	private String socketData;
	private String durability;
	private String requiredLevel;
	private String itemLevel;
	private String bonusDefenseSkillRating;
	private String bonusHitRating;
	private String bonusDodgeRating;
	private String itemSource;
	private ItemTooltip item;

	public Item(String armoryUrl, noNamespace.Item itemXml) throws XmlException {
		this.itemXml = itemXml;
		id = itemXml.getId();
		String xml = Utils.getArmoryXml(armoryUrl + "item-tooltip.xml?i=" + id);
		PageDocument itemDoc = PageDocument.Factory.parse(xml);
		// XML of the toolTip
		item = itemDoc.getPage().getItemTooltips().getItemTooltip();
		init(item);
	}

	private void init(ItemTooltip item) {
		name = item.getName().toString();
		icon = item.getIcon().toString();
		heroic = item.getHeroic();
		overallQualityId = "";
		bonding = item.getBonding();
		classId = "" + item.getClassId();
		equipData = item.getEquipData().getSubclassName();
		damageData = item.getDamageData();
		bonusStrength = item.getBonusStrength();
		bonusStamina = "" + item.getBonusStamina();
		// ca ca renvoie null normalement car 
		// il attaque la mauvaise armor du xsd
		armor = item.getArmor().getBase();
		socketData = item.getSocketData();
		durability = item.getDurability();
		requiredLevel = "" + item.getRequiredLevel();
		itemLevel = "" + item.getItemLevel();
		bonusDefenseSkillRating = item.getBonusDefenseSkillRating();
		bonusHitRating = "" + item.getBonusHitRating();
		bonusDodgeRating = item.getBonusDodgeRating();
		itemSource = item.getItemSource();
	}
	
	public ItemTooltip getItemXml() {
		return item;
	}

	public String getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public String getIcon() {
		return icon;
	}

	public String getHeroic() {
		return heroic;
	}

	public String getOverallQualityId() {
		return overallQualityId;
	}

	public String getBonding() {
		return bonding;
	}

	public String getClassId() {
		return classId;
	}

	public String getEquipData() {
		return equipData;
	}

	public String getDamageData() {
		return damageData;
	}

	public String getBonusStrength() {
		return bonusStrength;
	}

	public String getBonusStamina() {
		return bonusStamina;
	}

	public String getArmor() {
		return armor;
	}

	public String getSocketData() {
		return socketData;
	}

	public String getDurability() {
		return durability;
	}

	public String getRequiredLevel() {
		return requiredLevel;
	}

	public String getItemLevel() {
		return itemLevel;
	}

	public String getBonusDefenseSkillRating() {
		return bonusDefenseSkillRating;
	}

	public String getBonusHitRating() {
		return bonusHitRating;
	}

	public String getBonusDodgeRating() {
		return bonusDodgeRating;
	}

	public String getItemSource() {
		return itemSource;
	}


}
